using System;
using System.Windows.Forms;

namespace TimHeuer.WindowsLiveWriter.S34Writer
{
    public partial class S3Settings : Form
    {
        private string _accessKey;

        public string AccessKeyId
        {
            get { return _accessKey; }
        }
        
        private string _secretKey;

        public string SecretAccessKey
        {
            get { return _secretKey; }
        }

        private bool _autoUploadWithFileName;

        public bool AutoUploadWithFileName
        {
            get { return _autoUploadWithFileName; }
        }

        public S3Settings(S3Context context)
        {
            InitializeComponent();

            _accessKey = context.AccessKeyId;
            _secretKey = context.SecretAccessKey;
            _autoUploadWithFileName = context.AutoUploadWithFileName;
            
            AccessKey.Text = _accessKey;
            SecretKey.Text = _secretKey;
            AutoUpload.Checked = _autoUploadWithFileName;
        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            _accessKey = AccessKey.Text.Trim();
            _secretKey = SecretKey.Text.Trim();
            _autoUploadWithFileName = AutoUpload.Checked;

            base.DialogResult = DialogResult.OK;
        }

        private void ShowSecretText_CheckedChanged(object sender, EventArgs e)
        {
            SecretKey.UseSystemPasswordChar = !ShowSecretText.Checked;
        }
    }
}